package com.sishuok.jmstest.topic;

import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageProducer;
import javax.jms.Session;
import javax.jms.TextMessage;
import javax.jms.Topic;

import org.apache.activemq.ActiveMQConnectionFactory;

public class TransSender2 {
	public static void main(String[] args) throws Exception {
		ConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://172.16.15.111:61616");
		Connection connection = connectionFactory.createConnection();
		connection.start();
		
		Session session = connection.createSession(Boolean.TRUE, Session.AUTO_ACKNOWLEDGE);
		Topic destination = session.createTopic("my-topic");
		for(int i=0;i<2;i++){
			MessageProducer producer = session.createProducer(destination);
			for(int j=0;j<3;j++){
				TextMessage message = session.createTextMessage(i+"==message333--"+j);
				producer.send(message);
			}
			session.commit();
		}
		session.close();
		connection.close();
	}
}
